package com.hzspace.exception;

import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.WebRequest;

import java.util.Map;

/**
 * @Author: LiuHao
 * @Descirption:
 * @Date: 2020/2/28_23:27
 */
@Component
public class MyErrorAttributes extends DefaultErrorAttributes {

    /**
     * 自定义异常数据
     * @param request
     * @param includeStackTrace
     * @return
     */
    @Override
    public Map<String, Object> getErrorAttributes(WebRequest request, boolean includeStackTrace) {
        Map<String, Object> attributes = super.getErrorAttributes(request, includeStackTrace);
        attributes.put("errorMsg","System Busy!");
        return attributes;
    }
}
